<!DOCTYPE html>
<html>
  <head>
    <meta name="generator"
    content="HTML Tidy for HTML5 (experimental) for Windows https://github.com/w3c/tidy-html5/tree/c63cc39" />
    <title>linxx</title>
    <meta charset='utf-8' />
    <link href='https://dn-maxiang.qbox.me/res-min/themes/marxico.css' rel='stylesheet' />
  </head>
  <body>
    <div id='preview-contents' class='note-content'>
      <p><strong>linux环境安装mysql</strong></p>
      <hr />
      <pre class="prettyprint hljs-dark">
		<code class="hljs bash">						
			 <span class="hljs-keyword">1.下载</span>
			 wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
			 rpm -ivh mysql-community-release-el7-5.noarch.rpm	 
			 
			 <span class="hljs-keyword">2.安装命令</span>		 			 
			 yum install mysql-community-server
			 
			 <span class="hljs-keyword">3.查看是否安装成功</span>	
			 yum repolist enabled | grep "mysql.*-community.*"
			 
			 <span class="hljs-keyword">4.重启mysql</span>
			 service mysqld restart	
			 
			 <span class="hljs-keyword">5.初次安装无密码登入mysql</span>
			 mysql -uroot -p
			 
			 <span class="hljs-keyword">6.查看所有数据库</span>
			 show databases;
			 
			 <span class="hljs-keyword">7.选择mysql</span>
			 use mysql;
			 
			 <span class="hljs-keyword">8.设置root密码</span>
			 set password for 'root'@'localhost'=password('xxxx');
			 
			 <span class="hljs-keyword">9.把在所有数据库的所有表的所有权限赋值给位于所有IP地址的root用户。</span>
			 grant all privileges on *.* to root@'%'identified by 'password';
			 
			 <span class="hljs-keyword">10.如果是新用户而不是root，则要先新建用户</span>
			 create user 'username'@'%' identified by 'password';  
			 
			 <span class="hljs-keyword">11.配置默认编码为utf8</span>
			 修改/etc/my.cnf配置文件，在[mysqld]下添加编码配置，如下所示：
					[mysqld]
					character_set_server=utf8
					init_connect='SET NAMES utf8'
			 
			<span class="hljs-string">"imagename eq nginx.exe"</span>								
		</code>

	</pre>
	<blockquote>
		 <p>常用命令：</p>
		<ul>		
			<li>
				<p><strong>启动方式</strong>
					<br>
					1、使用 service 启动：service mysqld start
					<br>
					2、使用 mysqld 脚本启动：/etc/inint.d/mysqld start
					<br>
					3、使用 safe_mysqld 启动：safe_mysqld&
				</p>
			</li>
			<li>
				<p><strong>停止方式</strong>
					<br>
					1、使用 service 启动：service mysqld stop
					<br>
					2、使用 mysqld 脚本启动：/etc/inint.d/mysqld stop
					<br>
					3、 mysqladmin shutdown
				</p>
			</li>
			<li>
				<p><strong>重启</strong>
					<br>	
					1、使用 service 启动：service mysqld restart
					<br>
					2、使用 mysqld 脚本启动：/etc/inint.d/mysqld restart
				</p>
			</li>
		</ul>
	</blockquote>
    </div>
  </body>
</html>
